<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="UTF-8">
  <meta 
    name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <meta 
    http-equiv="X-UA-Compatible" 
    content="ie=edge">
  <meta 
    name="theme-color" 
    content="#fff" 
    id="theme-color">
  <meta 
    name="description" 
    content="程序员的快乐小网站">
  <link 
    rel="icon" 
    href="https://demo.theme-kaze.top/img/Kaze.png">
  <title>路由与交换技术（2）_虚拟局域网（VLAN）技术（上）</title>
  
    
      <meta 
        property="og:title" 
        content="路由与交换技术（2）_虚拟局域网（VLAN）技术（上）">
    
    
      <meta 
        property="og:url" 
        content="http://www.baikaihua.gitee.io/2021/10/24/%E8%B7%AF%E7%94%B1%E4%B8%8E%E4%BA%A4%E6%8D%A2%E6%8A%80%E6%9C%AF%EF%BC%882%EF%BC%89_%E8%99%9A%E6%8B%9F%E5%B1%80%E5%9F%9F%E7%BD%91%EF%BC%88VLAN%EF%BC%89%E6%8A%80%E6%9C%AF%EF%BC%88%E4%B8%8A%EF%BC%89/index.html">
    
    
      <meta 
        property="og:img" 
        content="https://gitee.com/baikaihua/tochang/raw/master/src=http___b-ssl.duitang.com_uploads_item_201607_07_20160707163006_EnLeG.jpeg&amp;refer=http___b-ssl.duitang.jpg">
    
    
      <meta 
        property="og:img" 
        content="&lt;p&gt;文章内容源自我对华为信息与网络技术学院教材中《路由与交换技术》一书的提炼与总结。本篇内容介绍了交VLAN中的一些概念和应用。&lt;/p&gt;
&lt;p&gt;整理：白开画&lt;/p&gt;">
    
    
      <meta 
        property="og:type" 
        content="article">
      <meta 
        property="og:article:published_time" 
        content="2021-10-24">
      <meta 
        property="og:article:modified_time" 
        content="2021-10-24">
      <meta 
        property="og:article:author" 
        content="白开画 and 徐威">
      
        
          <meta 
            property="og:article:tag" 
            content="网络">
        
          <meta 
            property="og:article:tag" 
            content="白开画">
        
          <meta 
            property="og:article:tag" 
            content="华为">
        
          <meta 
            property="og:article:tag" 
            content="路由交换">
        
          <meta 
            property="og:article:tag" 
            content="华为认证">
        
          <meta 
            property="og:article:tag" 
            content="VLAN">
        
          <meta 
            property="og:article:tag" 
            content="GVRP">
        
      
    
  
  <script>
    function loadScript(url, cb) {
      var script = document.createElement('script');
      script.src = url;
      if (cb) script.onload = cb;
      script.async = true;
      document.body.appendChild(script);
    }
    function loadCSS(href, data, attr) {
      var sheet = document.createElement('link');
      sheet.ref = 'stylesheet';
      sheet.href = href;
      sheet.dataset[data] = attr;
      document.head.appendChild(sheet);
    }
    function changeCSS(cssFile, data, attr) {
      var oldlink = document.querySelector(data);
      var newlink = document.createElement("link");
      newlink.setAttribute("rel", "stylesheet");
      newlink.setAttribute("href", cssFile);
      newlink.dataset.prism = attr;
      document.head.replaceChild(newlink, oldlink);
    }
  </script>
  
    
  
  <script>
    // control reverse button
    var reverseDarkList = {
      dark: 'light',
      light: 'dark'
    };
    var themeColor = {
      dark: '#1c1c1e',
      light: '#fff'
    }
    // get the data of css prefers-color-scheme
    var getCssMediaQuery = function() {
      return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
    };
    // reverse current darkmode setting function
    var reverseDarkModeSetting = function() {
      var setting = localStorage.getItem('user-color-scheme');
      if(reverseDarkList[setting]) {
        setting = reverseDarkList[setting];
      } else if(setting === null) {
        setting = reverseDarkList[getCssMediaQuery()];
      } else {
        return;
      }
      localStorage.setItem('user-color-scheme', setting);
      return setting;
    };
    // apply current darkmode setting
  </script>
  
    <script>
      var setDarkmode = function(mode) {
      var setting = mode || localStorage.getItem('user-color-scheme');
      if(setting === getCssMediaQuery()) {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else if(reverseDarkList[setting]) {
        document.documentElement.setAttribute('data-user-color-scheme', setting);
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
        document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
      }
    };
    setDarkmode();
    </script>
  
  
  <link rel="preload" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css" as="style" >
  <link rel="preload" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.js" as="script">
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lozad.min.js" as="script">
  
  
  
  
    
    <link rel="prefetch" href="//cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" as="script">
  
  
    
    <link rel="prefetch" href="//unpkg.com/valine/dist/Valine.min.js" as="script">
  
  
  
  <link rel="stylesheet" href="/css/main.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css">
  
    <link rel="stylesheet" href="/js/lib/lightbox/baguetteBox.min.css">
  
<meta name="generator" content="Hexo 5.4.0"></head>

  <body>
    <div class="wrapper">
       
      <nav class="navbar">
  <div class="navbar-logo">
    <span class="navbar-logo-main">
      
        <img 
          class="navbar-logo-img" 
          src="https://demo.theme-kaze.top/img/Kaze.png" 
          alt="blog logo">
      
      <span class="navbar-logo-dsc">程序小站</span>
    </span>
  </div>
  <div class="navbar-menu">
    
      <a 
        href="/" 
        class="navbar-menu-item">
        
          首页
        
      </a>
    
      <a 
        href="/archives" 
        class="navbar-menu-item">
        
          归档
        
      </a>
    
      <a 
        href="/tags" 
        class="navbar-menu-item">
        
          标签
        
      </a>
    
      <a 
        href="/categories" 
        class="navbar-menu-item">
        
          分类
        
      </a>
    
      <a 
        href="/about" 
        class="navbar-menu-item">
        
          关于
        
      </a>
    
    <a 
      class="navbar-menu-item darknavbar" 
      id="dark">
      <i class="iconfont icon-weather"></i>
    </a>
    <a 
      class="navbar-menu-item searchnavbar" 
      id="search">
      <i 
        class="iconfont icon-search" 
        style="font-size: 1.2rem; font-weight: 400;">
      </i>
    </a>
  </div>
</nav> 
      
      <div 
        id="local-search" 
        style="display: none">
        <input
          class="navbar-menu-item"
          id="search-input"
          placeholder="请输入搜索内容..." />
        <div id="search-content"></div>
      </div>
      
      <div class="section-wrap">
        <div class="container">
          <div class="columns">
            <main class="main-column">
<article class="card card-content">
  <header>
    <h1 class="post-title">
      路由与交换技术（2）_虚拟局域网（VLAN）技术（上）
    </h1>
  </header>
  <div class="post-meta post-show-meta">
    <time datetime="2021-10-24T11:58:33.592Z">
      <i 
        class="iconfont icon-calendar" 
        style="margin-right: 2px;">
      </i>
      <span>2021-10-24</span>
    </time>
    
      <span class="dot"></span>
      
        <a 
          href="/categories/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/" 
          class="post-meta-link">
          路由交换
        </a>
      
    
    
      <span class="dot"></span>
      <span>2.8k 字</span>
    
  </div>
  
    <div 
      class="post-meta post-show-meta" 
      style="margin-top: -10px;">
      <div style="display: flex; align-items: center;">
        <i 
          class="iconfont icon-biaoqian" 
          style="margin-right: 2px; font-size: 1.15rem;">
        </i>
        
          
          <a 
            href="/tags/%E7%BD%91%E7%BB%9C/" 
            class="post-meta-link">
            网络
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E7%99%BD%E5%BC%80%E7%94%BB/" 
            class="post-meta-link">
            白开画
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E5%8D%8E%E4%B8%BA/" 
            class="post-meta-link">
            华为
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/" 
            class="post-meta-link">
            路由交换
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E5%8D%8E%E4%B8%BA%E8%AE%A4%E8%AF%81/" 
            class="post-meta-link">
            华为认证
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/VLAN/" 
            class="post-meta-link">
            VLAN
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/GVRP/" 
            class="post-meta-link">
            GVRP
          </a>
        
      </div>
    </div>
  
  </header>
  <div 
    id="section" 
    class="post-content">
    <p>文章内容源自我对华为信息与网络技术学院教材中《路由与交换技术》一书的提炼与总结。本篇内容介绍了交VLAN中的一些概念和应用。</p>
<p>整理：白开画</p>
<span id="more"></span>
<h2 id="vlan基本理论"><a class="markdownIt-Anchor" href="#vlan基本理论"></a> VLAN基本理论</h2>
<h3 id="vlan的用途"><a class="markdownIt-Anchor" href="#vlan的用途"></a> VLAN的用途</h3>
<p>​		由若干台交换机以及与这些交换机连接的所有终端所组成的网络称之为交换网络，一个交换网络就是一个广播域。</p>
<p>​		VLAN技术能够在逻辑上把一个物理局域网分割为多个广播域，每个广播域称为一个“虚拟”局域网。</p>
<p>​		局域网解决了随着广播域扩大而带来的性能问题和安全性降低问题。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152246.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152246.jpg" class="lozad post-image"></p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152356.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152356.jpg" class="lozad post-image"></p>
<p>​		每台网络终端只能属于一个VLAN，属于一个VLAN的设备之间可以通过二层交换机直接通信而不必借助IP路由功能，属于不同VLAN的设备之间则只能通过IP路由功能才能实现通信。</p>
<h3 id="vlan的原理"><a class="markdownIt-Anchor" href="#vlan的原理"></a> VLAN的原理</h3>
<p>​		VLAN技术通过给数据帧插入VLAN标签的方式让交换机能够分辨出各个数据帧所属的VLAN。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152426.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152426.jpg" class="lozad post-image"></p>
<p>​		VLAN标签（VLAN tag）是用来区分数据帧所属VLAN的“贴纸”，是一个4字节长度的字段，它会以插入以太网数据帧头部的方式被“贴在”数据帧上。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152724.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018152724.jpg" class="lozad post-image"></p>
<p>​		VLAN标签被插入在源Mac地址后面，这个格式定义在IEEE 802.1Q标准中</p>
<p>​		VLAN标签的字段构成：</p>
<p>​		（1）TPID（标签协议标识符）：长度为2字节，取值为0x8100，用来表示这个数据帧携带了802.1Q标签。不支持802.1Q标准的设备在收到这样的数据帧后，会把它丢弃。</p>
<p>​		（2）TCI（标签控制信息）：长度为2字节。又细分为以下两个子字段，用来表示数据帧的控制信息。</p>
<ul>
<li>优先级（PRI）：长度为3比特，取值范围0~7，用来表示数据帧的优先级。优先级取值越大，数据帧的优先级越高。当交换机发生拥塞时，它会优先处理优先级高的数据帧。</li>
<li>CFI（规范格式指示器）：长度为1比特，取值非0即1。</li>
<li>VLAN ID（VLAN标识符）：长度为12比特，VLAN ID的作用顾名思义，这个字段的数字即为VLAN标签的数值。管理员能够配置的VLAN ID取值范围是1~4094。</li>
</ul>
<p>​		如果交换机上划分了多个VLAN，在交换机接受到广播数据帧时，它只会将这个数据帧从除了该数据帧入站端口之外，其他同VLAN的所有端口发送出去。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018154945.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018154945.jpg" class="lozad post-image"></p>
<p>​		如果交换机上划分了多个VLAN，那么当交换机接收到一个目的Mac地址不存在与自己Mac地址表中的单播数据帧时，它只会将这个数据帧从除了该入站端口之外，其他同VLAN的端口发送出去。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018155548.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211018155548.jpg" class="lozad post-image"></p>
<p>​		在不借助路由转发的大前提下，交换机不会将从一个VLAN的端口中接受到的数据帧，转发给任何其他VLAN中的端口。</p>
<p>​		在多VLAN环境中，即使交换机Mac地址表里保存了某数据帧目的Mac地址的条目，若这个目的Mac地址所对应的端口与数据帧的入站端口处于不同的VLAN中，交换机也显然不会通过Mac地址表中对应的那个端口吧这个数据转发出去。</p>
<p>​		处于不同VLAN无法通过Mac地址泛洪攻击来获取其他VLAN目的的单播数据帧。</p>
<h3 id="vlan在实际网络中的应用"><a class="markdownIt-Anchor" href="#vlan在实际网络中的应用"></a> VLAN在实际网络中的应用</h3>
<p>​		1.VLAN技术对网络的积极改变：</p>
<ul>
<li>增加了网络中广播域的数量，同时减少了每个广播域的规模，也就减少了每个广播域的终端设备的数量。</li>
<li>增加了网络安全性，管理员保障网络安全的手段增加了。</li>
<li>提高了网络设计的逻辑性，管理员可以规避地理、物理等因素对于网络设计的限制。</li>
</ul>
<p>​		*2.在网络设计中一个VLAN对应一个IP子网地址。管理员也可以在一个VLAN中配置多个IP子网地址。（不推荐）</p>
<h3 id="划分vlan的方法"><a class="markdownIt-Anchor" href="#划分vlan的方法"></a> 划分VLAN的方法</h3>
<p>​		1.<strong>基于源接口划分VLAN</strong>：管理员需手动绑定交换机接口与VLAN ID之间的关系。比如在一台48接口交换机上设置接口1~20属于VLAN 10，接口11~20属于VLAN 20，接口21~30属于VLAN 30等。这是最基础也是最常用的VLAN划分方法。这种方法的优点是配置简单，管理员想要把某个接口划分到某个VLAN中，只需要把该接口的PVID（接口VLAN ID）配置为相应的VLAN ID即可。缺点是当终端设备移动位置时，管理员很可能需要为终端设备连接的新接口重新划分VLAN：只有当终端设备移动前和移动后，它所连接的VLAN配置相同，管理员才无需重新为接口划分VLAN。</p>
<p>​		2.<strong>基于源Mac地址划分VLAN</strong>：管理员需要手动绑定终端设备网卡Mac地址与VLAN    ID之间的关系。在使用这种方法时，管理员前期工作量较大，需要建立完整的Mac地址与VLAN ID映射表，但好处在于一旦配置完成，即使终端设备移动位置，管理员也无需再次配置。当交换机从终端设备那里第一次收到数据帧时，它会根据数据帧Mac地址，查找Mac地址与VLAN ID映射表，以此来确定该数据帧所属的VLAN；这个判断过程与交换机是从哪个接口收到的数据帧并无关系。</p>
<p>​		3.<strong>基于源IP地址划分VLAN</strong>：管理员需要手动绑定IP子网地址与VLAN ID之间的关系。这种方法适用于使用静态IP地址的网络环境，好处与使用Mac地址划分VLAN相同，即使终端设备移动位置，管理员也无需再次配置接口的VLAN设置。当若网络中使用DHCP协议自动为终端设备分配IP地址，这就进入了先有鸡还是先有蛋的循环：交换机需要知道终端设备的IP地址才能为其分配VLAN，但终端设备上没有IP地址，它需要通过某个VLAN的DHCP服务器来获取IP地址。</p>
<h2 id="多交换机环境中的vlan"><a class="markdownIt-Anchor" href="#多交换机环境中的vlan"></a> 多交换机环境中的VLAN</h2>
<h3 id="跨交换机vlan原理"><a class="markdownIt-Anchor" href="#跨交换机vlan原理"></a> 跨交换机VLAN原理</h3>
<p>​		交换机的一大主要功能是连接各种类型的终端设备，这类设备大多不具备为自己生成的数据帧插入VLAN标签的功能，它们发出的数据帧被称为无标记帧，以此给这些无标记帧打上VLAN标签，成为了它们所连接交换机的任务。</p>
<p>​		PVID（接口默认的VLAN ID）是管理员给交换机接口配置的参数，这个参数的默认值为1。交换机通过每个接口的PVID。判断从这个接口收到的无标记帧应该属于哪个VLAN，并在进一步转发时，在数据帧中插入相应的VLAN标签。</p>
<p>​		*对于通过access端口接收到的无标记帧，交换机会先打标签再查表（即入站时打标），还是会先查表在打标签（即出站时打标），这项操纵都是各个厂商分别定义的，无公共标准。</p>
<p>​		根据是否打标签判断交换机接口类型：</p>
<p>​		（1）如果交换机某些接口连接的设备在正常情况下不会自行给数据帧打上VLAN标签，因而交换机通过这个接口收到的数据帧应为无标记帧，需要由交换机根据这些所在VLAN，为终端设备发来的数据帧打上VLAN标签；同时交换机在向这些接口连接的设备发送数据帧时也不应该打上VLAN标签的数据帧，那么管理员就应该把这类接口配置为access接口，access接口所连接的链路则称之为access链路。</p>
<p>​		（2）如果交换机某些接口所连接的设备会发来多个VLAN中的流量，为了区分这些流量，对端设备会给这些数据帧打上VLAN标签，所以交换机通过这个接口应该接收到的是标记帧；同时交换机也会为了让端设备能够区分自己发出流量所在的VLAN，因而给通过该接口发出的流量打上VLAN标签，那么管理员就应该把这类接口配置为trunk接口，相应的链路称之为trunk链路。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211024182528.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211024182528.jpg" class="lozad post-image"></p>
<h3 id="gvrp协议"><a class="markdownIt-Anchor" href="#gvrp协议"></a> GVRP协议</h3>
<p>​		GVRP基于GARP这一通用协议，GARP全程是通用属性注册协议，它的工作原理是把一个GARP成员上配置的属性信息，快速且精准地传播到整个交换网络中，这些属性通常是VLAN和组播地址。</p>
<p>​		GARP定义了交换机之间交互GARP报文的数据格式。GARP是基于IEEE 802.3以太网数据格式定义的，IEEE 802.3这一格式常用于网络管理。</p>
<p>​		GARP以01-80-C2-00-00-21作为目的组播地址，凡是启用GARP的设备都会加入这个组，并且监听发往这个组的消息。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211024184044.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211024184044.jpg" class="lozad post-image"></p>
<p>​		每个属性中包括以下字段：</p>
<p>​		（1）属性长度：标识该属性的长度，通常为2~255字节；</p>
<p>​		（2）属性事件：标识GARP支持的各种事件类型，取值范围0~5。</p>
<ul>
<li>0：表示LeaveAll事件，用来注销所以属性；</li>
<li>1：表示JoinEmpty事件，用来声明未注销的属性；</li>
<li>2：表示JoinIn事件，用来声明已注册的属性；</li>
<li>3：表示LeavesEmp事件，用来注销未注册的属性；</li>
<li>4：表示LeaveIn事件，用来注销已注册的属性；</li>
<li>5：表示Empty事件。</li>
</ul>
<p>​		（3）属性值：定义属性中的具体值。</p>
<p>​		*由管理员手动配置的VLAN称之为“静态VLAN”，而交换机通过GVRP自动学习到的VLAN则称之为“动态VLAN”。</p>
<p>​		管理员在启用GVRP时，既要在交换机全局启用该特性，也要在每一个相关接口启用该特性。启用GVRP的接口必须允许多个VLAN的流量通过，接口必须配置为Trunk接口。</p>
<p>​		GVRP支持的3种接口注册模式：</p>
<p>​		（1）Normal（普通）：这是GVRP的默认注册模式，到Trunk接口为Normal注册模式时，表示GVRP能够在该接口静态或动态创建、注册和注销VLAN，同时该接口能够发送有关静态VLAN和动态VLAN的声明消息。</p>
<p>​		（2）Fixed（固定）：当Trunk接口为Fixed注册模式时，GVRP不能再该接口注册或注销动态VLAN，只能发送静态VLAN的注册消息，该接口只会放行管理员手动配置的那些VLAN中的数据。</p>
<p>​		（3）Forbidden（禁止）：当Trunk接口为Forbidden注册模式时，GVRP不能再该接口上动态注册或注销VLAN，并且会删除接口上除VLAN 1之外的所有VLAN信息，只保留VLAN 1的信息，该接口值会放行VLAN 1的数据。</p>

  </div>
  <div>
    
      <div 
        class="post-note note-warning copyright" 
        style="margin-top: 42px">
        <p>
          <span style="font-weight: bold;">作者：</span><a 
            target="_blank" 
            rel="nofollow noopener noreferrer" 
            href="/about">
            白开画 and 徐威
          </a>
        </p>
        <p>
          <span style="font-weight: bold;">文章链接：</span><a 
            target="_blank" 
            rel="nofollow noopener noreferrer" 
            href="http://www.baikaihua.gitee.io/2021/10/24/%E8%B7%AF%E7%94%B1%E4%B8%8E%E4%BA%A4%E6%8D%A2%E6%8A%80%E6%9C%AF%EF%BC%882%EF%BC%89_%E8%99%9A%E6%8B%9F%E5%B1%80%E5%9F%9F%E7%BD%91%EF%BC%88VLAN%EF%BC%89%E6%8A%80%E6%9C%AF%EF%BC%88%E4%B8%8A%EF%BC%89/index.html">
            http://www.baikaihua.gitee.io/2021/10/24/%E8%B7%AF%E7%94%B1%E4%B8%8E%E4%BA%A4%E6%8D%A2%E6%8A%80%E6%9C%AF%EF%BC%882%EF%BC%89_%E8%99%9A%E6%8B%9F%E5%B1%80%E5%9F%9F%E7%BD%91%EF%BC%88VLAN%EF%BC%89%E6%8A%80%E6%9C%AF%EF%BC%88%E4%B8%8A%EF%BC%89/index.html
          </a>
        </p>
        <p><span style="font-weight: bold;">版权声明：</span>本博客所有文章除特别声明外，均采用<a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0 协议</a>。转载请注明出处！</p>
      </div>
    
  </div>
</article>
<div class="nav">
  
    <div class="nav-item-prev">
      <a 
        href="/2021/10/24/PHP%E8%BF%90%E7%AE%97%E7%AC%A6(2)/index.html" 
        class="nav-link">
        <i class="iconfont icon-left nav-prev-icon"></i>
        <div>
          <div class="nav-label">上一篇</div>
          
            <div class="nav-title">PHP运算符（2） </div>
          
        </div>
      </a>
    </div>
  
  
    <div class="nav-item-next">
      <a 
        href="/2021/10/16/PHP%E8%BF%90%E7%AE%97%E7%AC%A6(1)/index.html" 
        class="nav-link">
        <div>
          <div class="nav-label">下一篇</div>
          
            <div class="nav-title">PHP运算符（1） </div>
          
        </div>
        <i class="iconfont icon-right nav-next-icon"></i>
      </a>
    </div>
  
</div>

  <div 
    class="card card-content comment-card" 
    style="margin-top: 16px;">
    <div class="comment-card-title">评论</div>
    
  <div id="vcomments"></div>
  
  <script>
    loadScript("//unpkg.com/valine/dist/Valine.min.js");
    var oldLoadVa = window.onload;
    window.onload = function () {
      oldLoadVa && oldLoadVa();
      new Valine({
        el: '#vcomments',
        appId: 'C2ey5RzCeMGvikIpezIqS1fW-gzGzoHsz',
        appKey: 'yNj1HPpcuT4nFzgDG1hfxiwX',
        placeholder: 'Just go go',
        path: window.location.pathname,
        avatar: 'mp',
        meta: ["nick","mail","link"],
        pageSize: '10',
        lang: '',
        visitor: 'false',
        highlight: true,
        recordIP: false,
        
        
        
        enableQQ: 'false',
        requiredFields: [],
      });
    };
  </script>

  </div>

<div 
  class="card card-content toc-card" 
  id="mobiletoc">
  <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#vlan%E5%9F%BA%E6%9C%AC%E7%90%86%E8%AE%BA"><span class="toc-number">1.</span> <span class="toc-text"> VLAN基本理论</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E7%9A%84%E7%94%A8%E9%80%94"><span class="toc-number">1.1.</span> <span class="toc-text"> VLAN的用途</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E7%9A%84%E5%8E%9F%E7%90%86"><span class="toc-number">1.2.</span> <span class="toc-text"> VLAN的原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E5%9C%A8%E5%AE%9E%E9%99%85%E7%BD%91%E7%BB%9C%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8"><span class="toc-number">1.3.</span> <span class="toc-text"> VLAN在实际网络中的应用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%92%E5%88%86vlan%E7%9A%84%E6%96%B9%E6%B3%95"><span class="toc-number">1.4.</span> <span class="toc-text"> 划分VLAN的方法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%9A%E4%BA%A4%E6%8D%A2%E6%9C%BA%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84vlan"><span class="toc-number">2.</span> <span class="toc-text"> 多交换机环境中的VLAN</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%B7%A8%E4%BA%A4%E6%8D%A2%E6%9C%BAvlan%E5%8E%9F%E7%90%86"><span class="toc-number">2.1.</span> <span class="toc-text"> 跨交换机VLAN原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#gvrp%E5%8D%8F%E8%AE%AE"><span class="toc-number">2.2.</span> <span class="toc-text"> GVRP协议</span></a></li></ol></li></ol>
</div></main>
            <aside class="left-column">
              
              <div class="card card-author">
                
  <img 
    src="https://gitee.com/baikaihua/tochang/raw/master/src=http___b-ssl.duitang.com_uploads_item_201607_07_20160707163006_EnLeG.jpeg&refer=http___b-ssl.duitang.jpg" 
    class="author-img" 
    alt="author avatar">

<p class="author-name">白开画 and 徐威</p>
<p class="author-description">欢迎！</p>
<div class="author-message">
  <a 
    class="author-posts-count" 
    href="/archives">
    <span>33</span>
    <span>文章</span>
  </a>
  <a 
    class="author-categories-count" 
    href="/categories">
    <span>11</span>
    <span>分类</span>
  </a>
  <a 
    class="author-tags-count" 
    href="/tags">
    <span>37</span>
    <span>标签</span>
  </a>
</div>

              </div>
               <div class="sticky-tablet">
  
  
    <article class="display-when-two-columns spacer">
      <div class="card card-content toc-card">
        <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#vlan%E5%9F%BA%E6%9C%AC%E7%90%86%E8%AE%BA"><span class="toc-number">1.</span> <span class="toc-text"> VLAN基本理论</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E7%9A%84%E7%94%A8%E9%80%94"><span class="toc-number">1.1.</span> <span class="toc-text"> VLAN的用途</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E7%9A%84%E5%8E%9F%E7%90%86"><span class="toc-number">1.2.</span> <span class="toc-text"> VLAN的原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E5%9C%A8%E5%AE%9E%E9%99%85%E7%BD%91%E7%BB%9C%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8"><span class="toc-number">1.3.</span> <span class="toc-text"> VLAN在实际网络中的应用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%92%E5%88%86vlan%E7%9A%84%E6%96%B9%E6%B3%95"><span class="toc-number">1.4.</span> <span class="toc-text"> 划分VLAN的方法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%9A%E4%BA%A4%E6%8D%A2%E6%9C%BA%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84vlan"><span class="toc-number">2.</span> <span class="toc-text"> 多交换机环境中的VLAN</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%B7%A8%E4%BA%A4%E6%8D%A2%E6%9C%BAvlan%E5%8E%9F%E7%90%86"><span class="toc-number">2.1.</span> <span class="toc-text"> 跨交换机VLAN原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#gvrp%E5%8D%8F%E8%AE%AE"><span class="toc-number">2.2.</span> <span class="toc-text"> GVRP协议</span></a></li></ol></li></ol>
      </div>
    </article>
  
  
  <article class="card card-content categories-widget">
    <div class="categories-card">
  <div class="categories-header">
    <i 
      class="iconfont icon-fenlei" 
      style="padding-right: 2px;">
    </i>分类
  </div>
  <div class="categories-list">
    
      <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/">
        <div class="categories-list-item">
          计算机网络
          <span class="categories-list-item-badge">5</span>
        </div>
      </a>
    
      <a href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">
        <div class="categories-list-item">
          数据库
          <span class="categories-list-item-badge">3</span>
        </div>
      </a>
    
      <a href="/categories/PHP/">
        <div class="categories-list-item">
          PHP
          <span class="categories-list-item-badge">14</span>
        </div>
      </a>
    
      <a href="/categories/Windows%E7%B3%BB%E7%BB%9F/">
        <div class="categories-list-item">
          Windows系统
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/Python/">
        <div class="categories-list-item">
          Python
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/Linux/">
        <div class="categories-list-item">
          Linux
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">
        <div class="categories-list-item">
          数据结构与算法
          <span class="categories-list-item-badge">2</span>
        </div>
      </a>
    
      <a href="/categories/%E7%BD%91%E7%BB%9C/">
        <div class="categories-list-item">
          网络
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/">
        <div class="categories-list-item">
          路由交换
          <span class="categories-list-item-badge">3</span>
        </div>
      </a>
    
      <a href="/categories/%E8%BD%AC%E8%BD%BD/">
        <div class="categories-list-item">
          转载
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/python/">
        <div class="categories-list-item">
          python
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
  </div>
</div>
  </article>
  
  <article class="card card-content tags-widget">
    <div class="tags-card">
  <div class="tags-header">
    <i 
      class="iconfont icon-biaoqian" 
      style="padding-right: 2px;">
    </i>热门标签
  </div>
  <div class="tags-list">
    
      <a 
        href="/tags/%E7%99%BD%E5%BC%80%E7%94%BB/" 
        title="白开画">
        <div class="tags-list-item">白开画</div>
      </a>
    
      <a 
        href="/tags/%E5%BE%90%E5%A8%81/" 
        title="徐威">
        <div class="tags-list-item">徐威</div>
      </a>
    
      <a 
        href="/tags/PHP/" 
        title="PHP">
        <div class="tags-list-item">PHP</div>
      </a>
    
      <a 
        href="/tags/web%E8%84%9A%E6%9C%AC/" 
        title="web脚本">
        <div class="tags-list-item">web脚本</div>
      </a>
    
      <a 
        href="/tags/%E7%BD%91%E7%BB%9C/" 
        title="网络">
        <div class="tags-list-item">网络</div>
      </a>
    
      <a 
        href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" 
        title="计算机网络">
        <div class="tags-list-item">计算机网络</div>
      </a>
    
      <a 
        href="/tags/%E5%8D%8E%E4%B8%BA/" 
        title="华为">
        <div class="tags-list-item">华为</div>
      </a>
    
      <a 
        href="/tags/%E5%8D%8E%E4%B8%BA%E8%AE%A4%E8%AF%81/" 
        title="华为认证">
        <div class="tags-list-item">华为认证</div>
      </a>
    
      <a 
        href="/tags/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/" 
        title="路由交换">
        <div class="tags-list-item">路由交换</div>
      </a>
    
      <a 
        href="/tags/GVRP/" 
        title="GVRP">
        <div class="tags-list-item">GVRP</div>
      </a>
    
      <a 
        href="/tags/VLAN/" 
        title="VLAN">
        <div class="tags-list-item">VLAN</div>
      </a>
    
      <a 
        href="/tags/%E5%9F%BA%E7%A1%80/" 
        title="基础">
        <div class="tags-list-item">基础</div>
      </a>
    
      <a 
        href="/tags/ip/" 
        title="ip">
        <div class="tags-list-item">ip</div>
      </a>
    
      <a 
        href="/tags/%E5%A4%A7%E6%95%B0/" 
        title="大数">
        <div class="tags-list-item">大数</div>
      </a>
    
      <a 
        href="/tags/python/" 
        title="python">
        <div class="tags-list-item">python</div>
      </a>
    
      <a 
        href="/tags/%E5%91%BD%E4%BB%A4%E6%8F%90%E7%A4%BA%E7%AC%A6/" 
        title="命令提示符">
        <div class="tags-list-item">命令提示符</div>
      </a>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
            <aside class="right-column">
              <div class="sticky-widescreen">
  
  
    <article class="card card-content toc-card">
      <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#vlan%E5%9F%BA%E6%9C%AC%E7%90%86%E8%AE%BA"><span class="toc-number">1.</span> <span class="toc-text"> VLAN基本理论</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E7%9A%84%E7%94%A8%E9%80%94"><span class="toc-number">1.1.</span> <span class="toc-text"> VLAN的用途</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E7%9A%84%E5%8E%9F%E7%90%86"><span class="toc-number">1.2.</span> <span class="toc-text"> VLAN的原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vlan%E5%9C%A8%E5%AE%9E%E9%99%85%E7%BD%91%E7%BB%9C%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8"><span class="toc-number">1.3.</span> <span class="toc-text"> VLAN在实际网络中的应用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%92%E5%88%86vlan%E7%9A%84%E6%96%B9%E6%B3%95"><span class="toc-number">1.4.</span> <span class="toc-text"> 划分VLAN的方法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%9A%E4%BA%A4%E6%8D%A2%E6%9C%BA%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84vlan"><span class="toc-number">2.</span> <span class="toc-text"> 多交换机环境中的VLAN</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%B7%A8%E4%BA%A4%E6%8D%A2%E6%9C%BAvlan%E5%8E%9F%E7%90%86"><span class="toc-number">2.1.</span> <span class="toc-text"> 跨交换机VLAN原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#gvrp%E5%8D%8F%E8%AE%AE"><span class="toc-number">2.2.</span> <span class="toc-text"> GVRP协议</span></a></li></ol></li></ol>
    </article>
  
  
  <article class="card card-content">
    <div class="recent-posts-card">
  <div class="recent-posts-header">
    <i 
      class="iconfont icon-wenzhang_huaban" 
      style="padding-right: 2px;">
    </i>最近文章
  </div>
  <div class="recent-posts-list">
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-13</div>
        <a href="/2021/12/13/python%E7%88%AC%E5%8F%96%E6%B7%98%E5%AE%9D%E5%95%86%E5%93%81/index.html"><div class="recent-posts-item-content">python爬取淘宝商品</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-13</div>
        <a href="/2021/12/13/PHP%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/index.html"><div class="recent-posts-item-content">PHP字符串常用操作</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-11-29</div>
        <a href="/2021/11/29/PHP%E8%AE%A4%E8%AF%86%E5%AD%97%E7%AC%A6%E4%B8%B2/index.html"><div class="recent-posts-item-content">PHP认识字符串</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-11-21</div>
        <a href="/2021/11/21/PHP%E5%87%BD%E6%95%B0%E7%9A%84%E5%BA%94%E7%94%A8/index.html"><div class="recent-posts-item-content">PHP函数的应用</div></a>
      </div>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
          </div>
        </div>
      </div>
    </div>
     
    <footer class="footer">
  <div class="footer-container">
    <div>
      <div class="footer-dsc">
        <span>
          Copyright ©
          
            2021 -
          
          2021
        </span>
        &nbsp;
        <a 
          href="/" 
          class="footer-link">
          程序小站
        </a>
      </div>
    </div>

    
      <div class="footer-dsc">
        
          Powered by
          <a 
            href="https://hexo.io/" 
            class="footer-link" 
            target="_blank" 
            rel="nofollow noopener noreferrer">
            &nbsp;Hexo
          </a>
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          Theme -
          <a 
            href="https://github.com/theme-kaze" 
            class="footer-link" 
            target="_blank"
            rel="nofollow noopener noreferrer">
            &nbsp;Kaze
          </a>
        
      </div>
    
    
    
    
      <div class="footer-dsc">
        
          本站总访问量<span id="busuanzi_value_site_pv"></span>次
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          本站总访客数<span id="busuanzi_value_site_uv"></span>次
        
      </div>
      
    
</footer> 
    
  <a 
    role="button" 
    id="scrollbutton" 
    class="basebutton" 
    aria-label="回到顶部">
    <i class="iconfont icon-arrowleft button-icon"></i>
  </a>

<a 
  role="button" 
  id="menubutton" 
  class="basebutton">
  <i class="iconfont icon-menu button-icon"></i>
</a>
<a 
  role="button" 
  id="popbutton" 
  class="basebutton" 
  aria-label="控制中心">
  <i class="iconfont icon-expand button-icon"></i>
</a>
<a 
  role="button" 
  id="darkbutton" 
  class="basebutton darkwidget" 
  aria-label="夜色模式">
  <i class="iconfont icon-weather button-icon"></i>
</a>
<a 
  role="button" 
  id="searchbutton" 
  class="basebutton searchwidget" 
  aria-label="搜索">
  <i class="iconfont icon-search button-icon"></i>
</a> 
     
     
      

  
  
    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">

  
 
     
     
      <script>
  var addImgLayout = function () {
    var img = document.querySelectorAll('.post-content img')
    var i
    for (i = 0; i < img.length; i++) {
      var wrapper = document.createElement('a')
      wrapper.setAttribute('href', img[i].getAttribute('data-src'))
      wrapper.setAttribute('aria-label', 'illustration')
      wrapper.style.cssText =
        'width: 100%; display: flex; justify-content: center;'
      if (img[i].alt) wrapper.dataset.caption = img[i].alt
      wrapper.dataset.nolink = true
      img[i].before(wrapper)
      wrapper.append(img[i])
      var divWrap = document.createElement('div')
      divWrap.classList.add('gallery')
      wrapper.before(divWrap)
      divWrap.append(wrapper)
    }
    baguetteBox.run('.gallery')
  }
</script>
<script>
  loadScript(
    "/js/lib/lightbox/baguetteBox.min.js",
    addImgLayout
  )
</script>
 
     
     
    <script src="/js/main.js"></script> 
    
      <script> 
        loadScript('/js/lib/busuanzi.min.js') 
      </script>
     
    
      <script>
        var addLazyload = function () {
          var observer = lozad('.lozad', {
            load: function (el) {
              el.srcset = el.getAttribute('data-src')
            },
            loaded: function (el) {
              el.classList.add('loaded')
            },
          })
          observer.observe()
        }
      </script>
      <script>
        loadScript('/js/lib/lozad.min.js', addLazyload)
      </script>
     
    
    
      <script>
        setTimeout(() => {localSearch("search.json")}, 0)
      </script>
    
  </body>
</html>
